use t::MYTEST 'no_plan';

# PERL5LIB=.:$PERL5LIB prove t/core/log.t -v

# repeat_each。它其实是一个 perl 函数，默认情况下是 repeat_each(1)，表示测试案例只运行一次
repeat_each(1);
no_long_string();
no_root_location();

run_tests();


__DATA__
=== TEST 1: config white ip 127.0.0.1
--- config
    location /test1 {
        set $app_tmp "test";
        content_by_lua_block {
            ngx.say("done")
        }
    }

--- pipelined_requests eval
["GET /test1","GET /test1","GET /test1","GET /test1","GET /test1","GET /test1"]
--- error_code eval
[200,200,200,200,200,200]

=== TEST 2: config white ip 1.1.1.1
--- config
    location /test1 {
        set $app_tmp "test";
        content_by_lua_block {
            ngx.say("done")
        }
    }

--- pipelined_requests eval
["GET /test1","GET /test1","GET /test1","GET /test1","GET /test1","GET /test1"]
--- more_headers
x-connecting-ip: 1.1.1.1
--- error_code eval
[200,200,200,200,200,200]

=== TEST 3: config white ip 1.1.1.3
--- config
    location /test1 {
        set $app_tmp "test";
        content_by_lua_block {
            ngx.say("done")
        }
    }

--- pipelined_requests eval
["GET /test1","GET /test1","GET /test1","GET /test1","GET /test1","GET /test1"]
--- more_headers
x-connecting-ip: 1.1.1.3
--- error_code eval
[200,200,200,200,200,200]

=== TEST 4: black white ip 1.1.1.2
--- config
    location /test1 {
        set $app_tmp "test";
        content_by_lua_block {
            ngx.say("done")
        }
    }

--- pipelined_requests eval
["GET /test1","GET /test1","GET /test1","GET /test1","GET /test1","GET /test1"]
--- more_headers
x-connecting-ip: 1.1.1.2
--- error_code eval
[429,429,429,429,429,429]

=== TEST 5: black white ip 1.1.1.4
--- config
    location /test1 {
        set $app_tmp "test";
        content_by_lua_block {
            ngx.say("done")
        }
    }
--- pipelined_requests eval
["GET /test1","GET /test1","GET /test1","GET /test1","GET /test1","GET /test1"]
--- more_headers
x-connecting-ip: 1.1.1.4
--- error_code eval
[429,429,429,429,429,429]

=== TEST 6: frequency_limit.json rule1 1.1.1.5
--- config
    location /test1 {
        set $app_tmp "test";
        content_by_lua_block {
            ngx.say("done")
        }
    }

--- pipelined_requests eval
["GET /test1","GET /test1","GET /test1","GET /test1","GET /test1","GET /test1"]
--- more_headers
x-connecting-ip: 1.1.1.5
--- error_code eval
[200,200,200,429,429,429]

=== TEST 7: frequency_limit.json rule1 rule2 1.1.1.5

--- config

    location /test1 {
        set $app_tmp "test";
        content_by_lua_block {
            ngx.say("done")
        }
    }
    location /test2 {
        set $app_tmp "test";
        content_by_lua_block {
            ngx.say("done")
        }
    }

--- pipelined_requests eval
["GET /test1","GET /test1","GET /test1","GET /test1","GET /test1","GET /test2","GET /test2","GET /test2"]
--- more_headers
x-connecting-ip: 1.1.1.5
host: "www.mexc.com"
--- error_code eval
[200,200,200,429,429,200,200,429]
#这里需要单独跑，不然会收到TEST2的影响
# --- SKIP
--- ONLY
